import 'package:flutter/material.dart';
import 'package:flutter_screenutil/flutter_screenutil.dart';
import 'package:flutter_base/config/app_color.dart';

/// 按钮样式枚举
enum ButtonType {
  /// 主按钮 - 蓝色背景白色文字
  primary,
  
  /// 次要按钮 - 透明背景蓝色边框蓝色文字
  secondary,
  
  /// 禁用按钮 - 灰色背景白色文字
  disabled
}

/// 项目中通用确认按钮
class CommonButton extends StatelessWidget {
  /// 按钮文本
  final String title;
  
  /// 点击事件回调
  final Function()? onClick;
  
  /// 按钮样式
  final ButtonType type;
  
  /// 标准按钮
  const CommonButton({
    super.key,
    required this.title,
    this.onClick,
    this.type = ButtonType.primary,
  });
  
  /// 撑满宽度的按钮
  const CommonButton.expend({
    super.key,
    required this.title,
    this.onClick,
    this.type = ButtonType.primary,
  });

  @override
  Widget build(BuildContext context) {
    // 根据样式设置按钮颜色和文本颜色
    late Color backgroundColor;
    late Color textColor;
    BoxBorder? border;
    
    switch (type) {
      case ButtonType.primary:
        // 主按钮 - 蓝色背景白色文字
        backgroundColor = AppColor.primary; // 主色 #19DBF2
        textColor = Colors.white;
        border = null;
        break;
      case ButtonType.secondary:
        // 次要按钮 - 透明背景蓝色边框蓝色文字
        backgroundColor = Colors.transparent;
        textColor = AppColor.primary;
        border = Border.all(color: AppColor.primary, width: 1.w);
        break;
      case ButtonType.disabled:
        // 禁用按钮 - 灰色背景白色文字
        backgroundColor = AppColor.colorE4EBF0; // 灰色 #E4EBF0
        textColor = Colors.white;
        border = null;
        break;
    }
    
    // 是否可点击
    // final bool isClickable = type != ButtonType.disabled;

    return GestureDetector(
      onTap:  onClick ,
      child: Container(
        height: 48.w, // 固定高度为48
        width: double.infinity, // 默认撑满宽度
        decoration: BoxDecoration(
          color: backgroundColor,
          borderRadius: BorderRadius.circular(78.w), // 圆角半径
          border: border,
        ),
        child: Center(
          child: Text(
            title,
            style: TextStyle(
              color: textColor,
              fontSize: 16.sp,
              fontWeight: FontWeight.w600,

              fontFamily: 'Outfit', // 使用设计中的字体
            ),
            textAlign: TextAlign.center,
          ),
        ),
      ),
    );
  }
} 